package weiyao.xinxidasai.DTO;

import org.springframework.stereotype.Component;
import weiyao.xinxidasai.Utils.Encryption.Chaos.LogisticMap;
import weiyao.xinxidasai.Utils.ThreadLocal.UserHolder;
import weiyao.xinxidasai.pojo.Version;

import java.sql.Date;
import java.util.UUID;

import static weiyao.xinxidasai.Utils.Encryption.KeyIdGenerator.generateKeyId;


@Component
public class versioncreate {
    public static Version createVersion() {
        Version version = new Version();
        LogisticMap map = new LogisticMap();
        double[] params = map.getParams();
        version.setVersionId(generateKeyId(UserHolder.getUser().getUserId(),params[0],params[1],(long) params[2]));
        version.setUserId(UserHolder.getUser().getUserId());
        version.setR(params[0]);
        version.setX0(params[1]);
        version.setIterations((long) params[2]);
        version.setVersionNo(UUID.randomUUID().toString());
        version.setCreateTime(new Date(System.currentTimeMillis()));
        return version;
    }
}
